﻿using System;
using System.Collections.Generic;
using System.Text;
using ZhCun.Framework.DataAccess.DAL;

namespace ZhCun.Framework.DataAccess
{
    public class DALFactory
    {
        public static DalBase CreateDal(DatabaseTypeEnum dbType, string connStr)
        {
            DalBase dal = null;
            switch (dbType)
            {
                case DatabaseTypeEnum.SQLServer:
                    dal = new DalBaseSQL(connStr);
                    break;
                case DatabaseTypeEnum.SQLite:
                    dal = new DalBaseSQLite(connStr);
                    break;
                case DatabaseTypeEnum.Oracle:
                    throw new Exception("暂时不支持Oracle数据库.");
                default:
                    throw new Exception("dbType 参数貌似有问题噢.");
            }
            if (dal == null)
            {
                throw new Exception("创建Dal对象失败!");
            }
            return dal;
        }
    }
    /// <summary>
    /// 数据库类型
    /// </summary>
    public enum DatabaseTypeEnum
    {
        SQLServer,
        SQLite,
        Oracle
    }
}
